<%@ page contentType="text/html; charset=UTF-8" errorPage="/jsp/error.jsp" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld"  prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld"  prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/custom-html.tld" prefix="chtml" %>

<%@ page  import="java.util.ArrayList" %>
<%@ page  import="java.sql.Timestamp" %>

<%@ page  import="com.erp.framework.util.CommonUtil" %>
<%@ page  import="com.erp.app.admin.companyMenu.beans.CompanyMenuGroupVO" %>
<%@ page  import="com.erp.app.admin.companyMenu.web.CompanyMenuMaintenanceForm" %>
<%@ page  import="com.erp.app.admin.companyMenu.web.CompanyMenuObjectRow" %>
<%@ page  import="com.erp.app.common.ProjectConstants" %>
<%@ page  import="com.erp.app.util.web.WebUtil" %>


<jsp:useBean id="companyMenuMaintenanceForm" scope="session" type="com.erp.app.admin.companyMenu.web.CompanyMenuMaintenanceForm" />

<script language="javascript">

function doLoad() {
	<%
	if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE)).equals(ProjectConstants.GENERIC_YES)) {
		session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE);
		out.println("alert('Record saved.');");
	}
	String lastAction = (String) companyMenuMaintenanceForm.getPageEvent();
	if (lastAction != null && lastAction.startsWith("pEditRemark")) {
		out.println("window.open('remarkText.do','textWin','width=520,height=250,resizable=no,menubar=no,scrollbars=yes,status=no');");
	}

	%>
}

function changeVal(form, name, index, val) {
        //check is array or not
        if(form.elements[name].length == null){
                form.elements[name].value = val;
        } else {
                //array
                form.elements[name][index].value = val;
        }
}

var isSubmitted = 0;
function doSubmit(event, val) {
	if (isSubmitted == 0) {
		if(event == "exit"){
			if(!confirmExit("")){
				return false;
			}
		}
		isSubmitted = 1;
		document.forms[0].pageEvent.value = event;
		if (val != null) {
			document.forms[0].pageEventSrc.value = val;
		}
		document.forms[0].submit();
	}
}

</script>

<body onLoad="javascript:doLoad();">

<html:form action="/companyMenuMaintenance">
<html:hidden property="pageEventSrc" />
<html:hidden property="pageEvent" />
<html:hidden property="pageMode" />

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td>
	<chtml:button form="companyMenuMaintenanceForm" pageEvent="exit" styleClass="button1" />
	<chtml:button form="companyMenuMaintenanceForm" pageEvent="save" styleClass="button1" />
	<chtml:button form="companyMenuMaintenanceForm" pageEvent="search" styleClass="button1" />
	<chtml:button form="companyMenuMaintenanceForm" pageEvent="refresh" styleClass="button1" />
    </td>
</tr>
</table>
<%//System.out.println("companyMenuMaintenanceForm.getPageMode():"+companyMenuMaintenanceForm.getPageMode());%>
<font color='red'><html:errors /></font>

<html:hidden property="companyCode" />

<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
	<td width="150" class="col_label">Menu Group ID:</td>
	<td class="col_value">
		<html:hidden property="groupId"/>
		<bean:write name="companyMenuMaintenanceForm" property="groupId" filter="true"/>
	</td>
</tr>

<tr>
	<td width="150" class="col_label">Role Group ID:</td>
	<td class="col_value">
		<html:hidden property="roleGroupId"/>
		<bean:write name="companyMenuMaintenanceForm" property="roleGroupId" filter="true"/>
	</td>
</tr>


<% if (!CommonUtil.isEmpty(companyMenuMaintenanceForm.getMenuGroupVO())) { %>
<tr>
	<td width="150" class="col_label">Menu Name:</td>
	<td class="col_value">
		<bean:write name="companyMenuMaintenanceForm" property="menuGroupVO.menuName" filter="true" />
	</td>
</tr>
<% } %>

<tr>
	<td width="150" class="col_label">Menu ID:</td>
	<td class="col_value">
		<html:hidden property="menuId"/>
		<bean:write name="companyMenuMaintenanceForm" property="menuId" filter="true"/>
	</td>
</tr>

<% if (!CommonUtil.isEmpty(companyMenuMaintenanceForm.getMenuGroupVO())) { %>
<tr>
	<td width="150" class="col_label">Menu Type:</td>
	<td class="col_value">
		<bean:write name="companyMenuMaintenanceForm" property="menuGroupVO.menuType" filter="true" />
	</td>
</tr>
<tr>
	<td width="150" class="col_label">Menu Order:</td>
	<td class="col_value">
		<bean:write name="companyMenuMaintenanceForm" property="menuGroupVO.menuOrder" filter="true" />
	</td>
</tr>
<% } %>
<tr>
    <td width="150" class="col_label">View Level:</td>
    <td class="col_value">
	    <html:text property="viewLevel" size="5" maxlength="2" styleClass="t2" />
		</td>
</tr>
<tr>
    <td width="150" class="col_label">Create Level:</td>
    <td class="col_value">
	    <html:text property="createLevel" size="5" maxlength="2" styleClass="t2" />
		</td>
</tr>
<tr>
    <td width="150" class="col_label">Update Level:</td>
    <td class="col_value">
	    <html:text property="updateLevel" size="5" maxlength="2" styleClass="t2" />
		</td>
</tr>
<tr>
    <td width="150" class="col_label">Delete Level:</td>
    <td class="col_value">
	    <html:text property="deleteLevel" size="5" maxlength="2" styleClass="t2" />
		</td>
</tr>
</table>


<%
ArrayList menuObjectList = companyMenuMaintenanceForm.getMultiRows(0);
pageContext.setAttribute("menuObjectList", menuObjectList);
%>
<logic:equal name="companyMenuMaintenanceForm" property="folderIdx" value="0" >
<br><br>

<table bordercolor="#808080" cellspacing=1 cellpadding=2 width=859 border=0>
<tr>
	<td width="100" class="grid_header">Object ID:</td>
	<td width="100" class="grid_header">Object Name:</td>
	<td width="100" class="grid_header">Object Type:</td>
	<td width="100" class="grid_header">Object Action:</td>
	<td width="100" class="grid_header">Visible Level</td>
	<td width="100" class="grid_header">Enable Level</td>
</tr>
<logic:iterate id="menuObjectRow" name="menuObjectList" indexId="idx"  >
<%
    CompanyMenuObjectRow menuObject = (CompanyMenuObjectRow) menuObjectRow;
%>
<tr <%=(idx.intValue()%2 == 0)? "class=grid_result1": "class=grid_result2"%>> 
	<td class="t2">
		<%if (CommonUtil.nullToString(menuObject.getObjectExistInd()).equals(ProjectConstants.GENERIC_NO)) { %>
			<b><%= CommonUtil.nullToString(menuObject.getObjectId()) %></b>
	    <%} else { %>
			<%= CommonUtil.nullToString(menuObject.getObjectId()) %>
		<%} %>
<%--		<bean:write name="menuObjectRow" property="objectId" />--%>
		<html:hidden property="objectExistInd" value="<%= CommonUtil.nullToString(menuObject.getObjectExistInd()) %>" />
		<html:hidden property="objectId" value="<%= CommonUtil.nullToString(menuObject.getObjectId()) %>" />
		<html:hidden property="idx" value="<%=menuObject.getIdx()%>" />
		<html:hidden property="rowMode"  value="<%=menuObject.getRowMode()%>"/>
	</td>

<% if (CommonUtil.isEmpty(companyMenuMaintenanceForm.getMenuGroupVO())) { %>
	<td></td>
	<td></td>
	<td></td>
<% } %>


<% if (!CommonUtil.isEmpty(companyMenuMaintenanceForm.getMenuGroupVO())) { %>
	<td class="t2">
		<bean:write name="menuObjectRow" property="menuObjectVO.objectName" filter="true" />
	</td>
	<td class="t2">
		<bean:write name="menuObjectRow" property="menuObjectVO.objectType" filter="true" />
	</td>
	<td class="t2">
		<bean:write name="menuObjectRow" property="menuObjectVO.objectAction" filter="true" />
	</td>
<% } %>

	<td class="t2">
		<html:text property="visibleLevel" size="5" maxlength="2" styleClass="t2" value="<%= CommonUtil.nullToString(menuObject.getVisibleLevel()) %>" />
	</td>
	<td class="t2">
		<html:text property="enableLevel" size="5" maxlength="2" styleClass="t2" value="<%= CommonUtil.nullToString(menuObject.getEnableLevel()) %>" />
	</td>
</tr>
</logic:iterate>
</table>
</logic:equal>


</html:form>